<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.DriverManager"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.sql.SQLException"%>
<%@ page import="java.sql.Statement"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.List"%>
<%@ page import="cn.StudentBean"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=uft-8">
<title>修改学生详细信息</title>
<style type="text/css">
td, th {
	padding: 5px;
}
</style>
</head>
<body>


	<table width="98%" border="0" align="center" cellpadding="0"
		cellspacing="1" bgcolor="#666666">
		<tr>
			<th bgcolor="#FFFFFF">姓名</th>
			<th bgcolor="#FFFFFF">性别</th>
			<th bgcolor="#FFFFFF">年龄</th>
			<th bgcolor="#FFFFFF">学号</th>
			<th bgcolor="#FFFFFF">修改学生学号</th>
		</tr>


		<%
			Class.forName("com.mysql.jdbc.Driver");
			String url = "jdbc:mysql://localhost:3306/jsp";
			String username = "root";
			String password = "root";
			Connection conn = DriverManager.getConnection(url, username, password);
			Statement stmt = conn.createStatement();
			String sql = "select*from tb_student";
			ResultSet rs = stmt.executeQuery(sql);
			List<StudentBean> list = new ArrayList<>();
			while (rs.next()) {
				StudentBean student = new StudentBean();
				student.setName(rs.getString("name"));
				student.setSex(rs.getString("sex"));
				student.setAge(rs.getInt("age"));
				student.setNumber(rs.getInt("number"));

				list.add(student);
			}
		%>
		<%
			if (list == null || list.size() < 1) {
				out.print("<tr><td bgcolor='#FFFFFF' colspan='5'>没有学生信息</td></tr>");
			} else {
				for (StudentBean student : list) {
		%>
		<tr align="center">
			<td bgcolor="#FFFFFF"><%=student.getName()%></td>
			<td bgcolor="#FFFFFF"><%=student.getSex()%></td>
			<td bgcolor="#FFFFFF"><%=student.getAge()%></td>
			<td bgcolor="#FFFFFF"><%=student.getNumber()%></td>
			<td bgcolor="#FFFFFF">
				<form action="Servlet" method="post">
					<input type="hidden" name="name" value="<%=student.getName()%>">
					<input type="text" name="number" size="20"> 
					<input type="submit" value="修改">
				</form>
			</td>
		</tr>


		<%
			}
			}
		%>
	</table>
	<a href="student_system.jsp">返回</a>